<?php
// +----------------------------------------------------------------------
// | WoShiMaiJia Projcet 
// +----------------------------------------------------------------------
// | Copyright (c) 2010-2011 http://woshimaijia.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: xinqiyang <xinqiyang@gmail.com>
// +----------------------------------------------------------------------

class PubLogic extends BaseService
{
	
	public static function webPageIndex($params)
	{
		//get recent id from object then post he 
		$key = "l:pub";
		$pageSize = empty($params['p']) ? 20 : $params['p'];
		$from = empty($params['f']) ? 0 : $params['f'];
		$type = 'h:lastsay:';
		$usertype = 'h:';
		$idList = self::redisGetList($key, $from,$pageSize);
		if(!empty($idList)){
			$message = self::redisGetHashes($idList,$type);
			$user = self::redisGetHashes($idList);
			if(!empty($message) && !empty($user))
			{
				$arr['message'] = $message;
				$arr['user'] = $user;
				return $arr;
			}
		}
		logWarning(__CLASS__.'/'.__FUNCTION__.':get message and user error  ');
		return false;
	}
	
	public static function actSetMessage()
	{
		$key = "l:pub";
		$where = "SELECT DISTINCT user_id FROM __TABLE__ WHERE object='say'  ORDER BY ID DESC LIMIT 500";
		$list = self::query('post',$where);
		if(!empty($list))
		{
			return self::redisSetList($key, datasetToArray($list,'user_id'));
		}
		return false;
	}
	
	
	
}